<?php
class BookDetailPageModel extends PageModel {
	
	public $usersHasBook;
	
    /**
     * Return book condition string.
     */
	public function getBookConditionString($user) {
		$userBookCondition = new UserBookCondition();
		$ret = "";
		$userBook = Book::getUserBook(parent::getBook(), $user);
		$conditionArr = explode(",", $userBook->condition);
		foreach ($conditionArr as $conditionId) {
			$condition = $userBookCondition->findById($conditionId);
			$ret.=($condition->condition.",");
		}
		return $ret;
	}
	
    /**
     * Return book usage string.
     */
    public function getBookUsageString($user) {
        $userBookUsage = new UserBookUsage();
        $ret = "";
        $userBook = Book::getUserBook(parent::getBook(), $user);
        $usageArr = explode(",", $userBook->usage);
        foreach ($usageArr as $usageId) {
            $usage = $userBookUsage->findById($usageId);
            $ret.=($usage->usage.",");
        }
        return $ret;
    }
    
    /**
     * Return user book message.
     * 
     * @param $user
     */
    public function getUserBookNote($user) {
        $userBook = Book::getUserBook(parent::getBook(), $user);
        return $userBook->note;
    }
}
?>